let financeType={
    "fukuang":"0",//付款
    "shoukuang":"1",//收款
};

let contractDefault={
    id:"1",//合同id

};//默认合同

let roleObj={
    "supplierRole":"1",//供应商角色
    "zuHuRole":"1",//租户角色
};
//合同类型
var contractTypeObj = {
    "buy":"0",//采购
    "sell":"1",//销售
};
// 弹出层指定宽度
function openWin(title, url,callback, width, height) {
    // 如果是移动端，就使用自适应大小弹窗
    if ($.common.isEmpty(width)) {
        width = 1200;
    }
    if ($.common.isEmpty(height)) {
        height = ($(window).height() - 50);
    }
    top.layer.open({
        type: 2,
        area: [width + 'px', height + 'px'],
        fix: false,
        //不固定
        maxmin: true,
        shade: 0.3,
        title: title,
        content: url,
        btn: ['关闭'],
        // 弹层外区域关闭
        shadeClose: true,
        end: function () {
            $.table.refresh();
        },
        success: function () {
            $(':focus').blur();
        }
    });
}
function openWinRefresh(title,url) {
    $.modal.open(title,url,1200,($(window).height() - 50),function (index, layero) {
        var iframeWin = layero.find('iframe')[0];
        iframeWin.contentWindow.submitHandler(index, layero);
        setTimeout(function () {
            $.table.refresh();
        },500);

    });
}

function isEmptyString(str) {
    if (str === null || str === undefined || str === '' || str === "null") {
        return true; // 字符串为空
    } else {
        return false; // 字符串不为空
    }
}

function openWindOptions(title,url,width,height,btns){
    table.set();
    var options = {
        title: title,
        width: width||($(window).width()),
        height: height||($(window).height()-50),
        url: url,
        skin: 'layui-layer-gray',
        btn:isEmptyString(btns)?['关闭']:btns,
        // 弹层外区域关闭
        shadeClose: false,
        yes: function (index, layero) {
            $.modal.close(index);
        }
    };
    $.modal.openOptions(options);
}

function printPageBuilder(table) {
    return `
        	<html>
        	  <head>
        	  <style type="text/css" media="print">
        	  @page {
        	    size: auto;
        	    margin: 25px 0 25px 0;
        	  }
        	  </style>
        	  <style type="text/css" media="all">
        	  table {
        	    border-collapse: collapse;
        	    font-size: 12px;
        	  }
        	  table, th, td {
        	    border: 1px solid grey;
        	  }
        	  th, td {
        	    text-align: center;
        	    vertical-align: middle;
        	  }
        	  p {
        	    font-weight: bold;
        	    margin-left:20px;
        	  }
        	  table {
        	    width:94%;
        	    margin-left:3%;
        	    margin-right:3%;
        	  }
        	  div.bs-table-print {
        	    text-align:center;
        	  }
        	  </style>
        	  </head>
        	  <title>Print Table</title>
        	  <body>
        	  <div class="bs-table-print">${table}</div>
        	  </body>
        	</html>`
}
